/**
 *  @file SyncLock.h
 */
#ifndef _SYNCLOCK_H_
#define _SYNCLOCK_H_

#include "../common/BaseObject.h"

namespace cppflib
{

namespace threading
{

/**
 *  A lock object to mark a piece of code which should be inside a critical section,
 *  internally it is a CRITICAL_SECTION on Windows and a pthread_mutex_t on Linux.
 *
 *  Put the critical section of code between 'Lock' and 'Unlock' or use 'SyncWrap' to
 *  utilize it in a easier way
 */
class _DLLAPI SyncLock : public BaseObject
{
private:
    ptrany_t pSyncObj;

public:
    SyncLock(void);
    virtual ~SyncLock(void);

    bool TryLock(void);
    void Lock(void);
    void Unlock(void);
    void Close(void);
};

} // end of namespace threading


} // end of namespace cppflib



#endif
